package org.csu.webjpetstoreback.controller;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraintvalidation.SupportedValidationTarget;
import org.csu.webjpetstoreback.config.CommonResponse;
import org.csu.webjpetstoreback.model.Account;
import org.csu.webjpetstoreback.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttributes;

import java.util.List;

@RestController
@SessionAttributes(names = "httpSession")
@Validated
public class AccountController {
//    @GetMapping("/Account")
//    public CommonResponse<Account> testRequest(){
//        Account account = new Account();
//        account.userid = "china";
//        account.city="1";
//        account.addr1="2";
//        account.addr2="3";
//        account.country="12";
//        account.favcategory="0";
//        account.firstname = "10";
//        account.lastname="12";
//        account.phone = "12";
//        account.state = "12";
//        account.status = "12";
//        account.zip = "100";
//        account.email = "10";
//        accountService.PostAccount(account);
//        account.zip=null;
//        account.state="10086";
//        accountService.PutAccount(account);
//        accountService.DeleteAccount(account.userid);
//        return CommonResponse.BackForSuccess(account);
//    }

    @Autowired
    private AccountService accountService;

    @GetMapping("/Account2")
    public CommonResponse<List<Account>> testRequest2(){
        return accountService.GetAccount();
    }


}
